package com.jch.demo.intro;

public class ArithmeticCalculatorLoggingImpl implements ArithmeticCalculator {
    @Override
    public double add(double a, double b) {
        if (a < 0 || b < 0){
            throw new IllegalArgumentException("Positive numbers only");
        }
        System.out.println("before add params a="+ a +",b="+b);
        double result = a + b;
        System.out.println("end add result="+result);
        return result;
    }

    @Override
    public double sub(double a, double b) {
        if (a < 0 || b < 0){
            throw new IllegalArgumentException("Positive numbers only");
        }
        System.out.println("before sub params a=" + a + ",b=" +b);
        double result = a - b;
        System.out.println("end sub result=" + result);
        return result;
    }

    @Override
    public double mul(double a, double b) {
        if (a < 0 || b < 0){
            throw new IllegalArgumentException("Positive numbers only");
        }
        System.out.println("before mul params a=" + a + ",b="+b);
        double result = a * b;
        System.out.println("end mul result=" + result);
        return result;
    }

    @Override
    public double div(double a, double b) {
        if (a < 0 || b < 0){
            throw new IllegalArgumentException("Positive numbers only");
        }
        System.out.println("before div params a=" + a + ",b="+b);
        double result = a / b;
        System.out.println("end result=" + result);
        return result;
    }
}
